<%--
  Created by IntelliJ IDEA.
  User: 22328
  Date: 2021/2/14
  Time: 23:53
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html class="x-admin-sm">
<head>
    <meta charset="UTF-8">
    <title>广告编辑</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
</head>
<body>
<div class="layui-fluid">
    <div class="layui-row">
        <form class="layui-form layui-form-pane" onsubmit="return false">
            <div class="layui-form-item" style="display: none">
                <label for="id" class="layui-form-label">
                    ID
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="id" name="id" value="${advertisementInfo.id}"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="companyName" class="layui-form-label">
                    公司名
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="companyName" name="companyName" value="${advertisementInfo.companyName}"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="advertisementMoney" class="layui-form-label">
                    广告费
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="advertisementMoney" name="advertisementMoney" value="${advertisementInfo.advertisementMoney}"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="gmtCreate" class="layui-form-label">
                    开始时间
                </label>
                <div class="layui-input-inline">
                    <input type="date" id="gmtCreate" name="gmtCreate" value="${advertisementInfo.gmtCreate}"
                           class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label for="gmtEnd" class="layui-form-label">
                    结束时间
                </label>
                <div class="layui-input-inline">
                    <input type="date" id="gmtEnd" name="gmtEnd" value="${advertisementInfo.gmtEnd}" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">类型</label>
                <div class="layui-input-inline">
                    <select id="advertisementType" name="advertisementType">
                        <c:if test="${advertisementInfo.advertisementType=='轮播图'}">
                            <option value="轮播图">轮播图</option>
                            <option value="静图">静图</option>
                        </c:if>
                        <c:if test="${advertisementInfo.advertisementType=='静图'}">
                            <option value="静图">静图</option>
                            <option value="轮播图">轮播图</option>
                        </c:if>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <label for="advertisementImg" class="layui-form-label">
                    图片
                </label>
                <div class="layui-input-inline">
                    <input type="text" id="advertisementImg" name="advertisementImg" value="" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <button id="add_btn" class="layui-btn">
                    修改
                </button>
            </div>
        </form>
    </div>
</div>
</body>
<script src="./js/jquery-3.1.0.min.js" type="text/javascript"></script>
<script>
    layui.use(['form', 'layer'], function () {
        var form = layui.form,
            layer = layui.layer;
    });
    $(function () {
        $("#add_btn").click(function () {
            var id = $("#id").val();
            var companyName = $("#companyName").val();
            var advertisementMoney = $("#advertisementMoney").val();
            var gmtCreate = $("#gmtCreate").val();
            var gmtEnd = $("#gmtEnd").val();
            var advertisementType = $("#advertisementType").val();
            var advertisementImg = $("#advertisementImg").val();
            $.ajax({
                url: "./updateAdvertisement",
                type: "post",
                data: {
                    id:id,
                    companyName: companyName,
                    advertisementMoney: advertisementMoney,
                    gmtCreate: gmtCreate,
                    gmtEnd: gmtEnd,
                    advertisementType: advertisementType,
                    advertisementImg: advertisementImg
                },
                success: function (res) {
                    if (res.data === "修改成功") {
                        layer.alert("修改成功", {
                                icon: 6
                            },
                            function () {
                                //关闭当前frame
                                xadmin.close();
                                // 可以对父窗口进行刷新
                                xadmin.father_reload();
                            });
                    } else {
                        layer.msg("修改失败");
                    }
                },
                error: function () {
                    alert("404.html页面");
                }
            });
        });
    });
</script>
</html>

